﻿

using AutoMapper;
using DataBase;
using DB.SDFAuth;
using SDFAuth.Models;

namespace Nop.Admin
{
    public static class MappingExtensions
    {
        public static LoginModel ToModel(this user entity)
        {
            return Mapper.Map<user, LoginModel>(entity);
        }

        public static user ToEntity(this LoginModel model, user destination = null)
        {
            if (destination == null)
            {
                return Mapper.Map<LoginModel, user>(model);    
            }
            else
            {
                return Mapper.Map(model, destination);
            }
            
        }

        public static CityModel ToModel(this UserCity entity)
        {
            return Mapper.Map<UserCity, CityModel>(entity);
        }
        public static PcdModel ToPcdModel(this CityModel model)
        {
            return Mapper.Map<CityModel, PcdModel>(model);
        }

        public static UserCity ToEntity(this CityModel model, UserCity destination = null)
        {
            if (destination == null)
            {
                return Mapper.Map<CityModel, UserCity>(model);
            }
            else
            {
                return Mapper.Map(model, destination);
            }

        }
    }
}